package com.learn.designPatterns.createType.singleton;

/**
 * @classname:
 * @Description: 静态内部类实现
 * @author: yfpu
 * @Date: 2018-08-21 17:45
 */
public class Singleton5_Static_Internal {

    /**
     * 当 Singleton 类加载时，静态内部类 SingletonHolder 没有被加载进内存。只有当调用 getInstance()方法从而触发
     * SingletonHolder.SINGLETONf 时 SingletonHolder才会被加载，此时初始化 INSTANCE 实例。
     */


    private Singleton5_Static_Internal() {
    }

    private static class SingletonHolder {
        private static final Singleton5_Static_Internal SINGLETON = new Singleton5_Static_Internal();
    }

    public static Singleton5_Static_Internal getInstance() {
        return SingletonHolder.SINGLETON;
    }


}
